package com.cn.web.theme.controller;

import com.cn.annoation.NoLogin;
import com.cn.config.SmsCodeTemplateConfig;
import com.cn.msg.ResultMsg;
import com.cn.theme.ThemeVO;
import com.cn.util.BaseController;
import com.cn.web.theme.service.ThemeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * description: ThemeController <br>
 * date: 23.1.5 11:40 <br>
 * author: cn_yaojin <br>
 * version: 1.0 <br>
 */
@RestController
@RequestMapping(value = "admin/theme")
@Api(tags = "主题设置")
@Slf4j
public class ThemeController extends BaseController {

    @Autowired
    private ThemeService themeService;


    @Autowired
    private SmsCodeTemplateConfig smsCodeTemplateConfig;

    @ApiOperation(value = "获取主题")
    @NoLogin
    @GetMapping(value = "find")
    public ResultMsg<ThemeVO> find() {
        return ResultMsg.builder().setData(this.themeService.find());
    }

    @ApiOperation(value = "编辑")
    @PostMapping(value = "edit")
    public ResultMsg edit(
            @RequestBody ThemeVO info
    ) {
        this.themeService.edit(info);
        return ResultMsg.builder();
    }

    @GetMapping("test")
    public ResultMsg test() {
        String token = request.getHeader("token");
        if (StringUtils.isEmpty(token)) {
            return ResultMsg.builder().setSuccess(false);
        }
        return ResultMsg.builder();
    }

    public static void main(String[] args) {
        System.out.println(System.currentTimeMillis());
    }

}
